#!/usr/bin/env python
# vim:fileencoding=utf-8

from calibre.web.feeds.news import BasicNewsRecipe


class NewTab(BasicNewsRecipe):
    title = '\u041D\u043E\u0432\u0430\u044F \u0432\u043A\u043B\u0430\u0434\u043A\u0430'
    __author__ = 'bugmen00t'
    description = '\u041F\u043B\u043E\u0449\u0430\u0434\u043A\u0430 \u0434\u043B\u044F \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438 \u0440\u0435\u043F\u043E\u0440\u0442\u0430\u0436\u0435\u0439 \u0438 \u0437\u0430\u043C\u0435\u0442\u043E\u043A \u043E \u0442\u043E\u043C, \u043A\u0430\u043A \u043C\u0435\u043D\u044F\u044E\u0442\u0441\u044F \u0440\u0435\u0433\u0438\u043E\u043D\u044B \u0420\u043E\u0441\u0441\u0438\u0438 \u043F\u043E\u0441\u043B\u0435 24 \u0444\u0435\u0432\u0440\u0430\u043B\u044F 2022 \u0433\u043E\u0434\u0430.'  # noqa
    publisher = '\u041C\u0438\u0445\u0430\u0438\u043B \u0414\u0430\u043D\u0438\u043B\u043E\u0432\u0438\u0447'
    category = 'blog'
    cover_url = u'https://static.tildacdn.com/tild3765-3961-4337-b366-323437626331/thenewtab-sn.jpg'
    language = 'ru'
    no_stylesheets = True
    remove_javascript = False
    auto_cleanup = False
    oldest_article = 30
    max_articles_per_feed = 10

    remove_tags_before = dict(name='h1')

    remove_tags = [
        dict(name='div', attrs={'class': 't-popup'}),
        dict(name='div', attrs={'class': 't185'}),
        dict(name='div', attrs={'class': 't403'}),
        dict(name='div', attrs={'class': 't404'}),
        dict(name='div', attrs={'class': 't134'}),
        dict(name='div', attrs={'class': 'sp-form-fields-wrapper'})
    ]

    feeds = [
        ('\u041D\u043E\u0432\u0430\u044F \u0432\u043A\u043B\u0430\u0434\u043A\u0430','https://thenewtab.io/feed/')
        ]

    def preprocess_html(self, soup):
        for img in soup.findAll('img', attrs={'data-original': True}):
            img['src'] = img['data-original']
        return soup
